import FlvPlayer from './FlvPlayer.vue';
// import FrameMixin from '../player-frame/FrameMixin.jsx';

export default {
  name: 'FlvPlayer',
  // mixins: [FrameMixin],
  components: { FlvPlayer },
  data() {
    return { url: null };
  },
  methods: {
    async onVideoOptionChange() {
      const { cameraCode, startTime, endTime } = this.videoOption;
      const params = { cameraCode };
      if (this.isPlayback === true) {
        const formatter = 'YYYY-MM-DDTHH:mm:SS.SSSZ';
        params.startTime = startTime.format(formatter);
        params.endTime = endTime.format(formatter);
      }
      if (params.cameraCode) {
        const res = await rtspToRtmp(params);
        this.url = (res && res.data) || '';
      }
    },
  },
  render() {
    return this.renderTemplate(() => (
      <FlvPlayer
        {...{
          // {streamUrl, autoplay, options}
          props: { streamUrl: this.url },
          on: { close: this.onVideoClose },
        }}
      />
    ));
  },
};
